// pages/entry/login.js
//获取应用实例
const util = require('../../utils/util.js');
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },
  //首页数据获取
  formSubmit: function (e) {
    var _this = this;
    console.log();
    var loginInfo = e.detail.value;
    if (loginInfo.phone==""||loginInfo.password==""){
      wx.showToast({
        title: '您的信息输入不正确',
        icon: 'none',
        duration: 2000
      });
      return;
    }
    var url = app.globalData.domain + 'member/login';
    util.wxPOSTRequest(url, loginInfo, data => {
      console.log(data.data);
      if (data.data == "") {
        wx.showToast({
          title: data.meg,
          icon: 'none',
          duration: 2000
        });
        return;
      }
      if (data.data.member.status!=1) {
        wx.showToast({
          title: "登录失败",
          icon: 'none',
          duration: 2000
        });
        return;
      }
      wx.setStorage({
        key: "loginState",
        data: "1"
      });
      wx.showToast({
        title: "登录成功",
        icon: 'success',
        duration: 2000
      });
      setTimeout(function(){
        wx.switchTab({
          url: '../index/index',
        });
      },2000)
    }, data => {
      wx.showToast({
        title: data.meg,
        icon: 'none',
        duration: 2000
      })
    }, data => { });
  },
})